package com.rainbow.controller

import cn.hutool.core.lang.Console
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import java.security.Principal

@Controller
class UserController {

    @GetMapping("/user")
    fun user(@AuthenticationPrincipal principal: Principal, model: Model): String {
        Console.log(SecurityContextHolder.getContext().authentication)
        model.addAttribute("username", principal.name)
        return "user/user"
    }

}